﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace API.Controllers
{
    [API.Core.ActionFilters.Throttle(Name = "CommonControllerAsync", Milliseconds = 500)]
    public class CommonControllerAsync : AsyncController
    {
        public virtual string _ip { get { return Request.RequestContext.HttpContext.Request.UserHostAddress; } }
        public virtual string _api_key { get { return Request["api_key"]; } }

        public CommonControllerAsync() { }

        protected override void OnException(ExceptionContext filterContext)
        {
            filterContext.Result = new JsonResult
            {
                Data = new API.Core.CommonSimpleResponse(filterContext.Exception),
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            base.OnException(filterContext);
        }
    }
}